package groovy
/**
 * plan C
 *
 * 1、开发编写类似于如下代码
 * String prettify(String sex){
 *  return "abc${sex}bcd";
 * }
 *
 * 2、 包装闭包函数 execAndLog到函数
 *  def prettify = execAndLog.curry(this.&prettify)
 *
 * 4、 调用方直接调用prettify("aaaaa") 即可
 */
String prettify(String sex){
    return "abc${sex}bcd";
}

def execAndLog = { func,args ->
    long s = System.currentTimeMillis();
    def result = func.call(args)
    long e = System.currentTimeMillis();
    long duration = e - s;
    println(" MOP耗费时间：" + duration);
    return result;
}

def prettify = execAndLog.curry(this.&prettify)

print(prettify("aaaa"))